// pages/my/orderDetail/orderDetail.js
const utils = require("../../../utils/utils.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:{},
    id:'',
    pdbottom:0,
    btnHeight:0,
    firstOpen:0
  },
  sqtk(e){
      var amount = e.currentTarget.dataset.amount;
      var icon = e.currentTarget.dataset.icon;
      var name = e.currentTarget.dataset.name;
      var taskno = e.currentTarget.dataset.taskno;
      var tel = e.currentTarget.dataset.tel;
      wx.navigateTo({
        url: '/pages/my/applyRefund/applyRefund?amount='+amount+'&icon='+icon+'&name='+name+'&taskno='+taskno+'&mobile='+this.data.mobile,
      })  
  },
  printAgain(e){
    var id = e.currentTarget.dataset.id;
    wx.showLoading({
      title: '请稍候',
    })
    utils.request('Member/taskAgain',{taskId:id}, function (res) {
      if (res.data.code == 1) {
          wx.navigateTo({
            url: '../../print/paySuccess/paySuccess?type=1',
          })
      } else {
        wx.hideLoading()
        utils.toast(res.data.msg)
      }
    })
  },
  prive(e){
    var url = e.currentTarget.dataset.url;
    var title = e.currentTarget.dataset.title;
    var type = e.currentTarget.dataset.type;
    wx.showLoading()
    if(type=='pdf'){
        wx.hideLoading()
        wx.navigateTo({
            url: '/pages/my/pdfsee/pdfsee?url='+url+'&name='+title
        })
    }else{
      wx.hideLoading()
      wx.previewImage({
        current:url, // 当前显示图片的http链接
        urls:[url] // 需要预览的图片http链接列表
      })

    }
  },
  goELeloc(e){
    wx.navigateTo({
      url: '/pages/my/locsMap/locsMap?id='+this.data.id,
    })
  },
  wxContant(e){
    var url = e.currentTarget.dataset.url;
    var id = e.currentTarget.dataset.id;
    var code = e.currentTarget.dataset.code;
    wx.openCustomerServiceChat({
        extInfo: {url:url},
        corpId:id?id:'ww788deee02e0b4ed7',
        showMessageCard:true,
        sendMessageTitle:'打印订单详情',
        sendMessagePath:'/pages/my/orderDetail/orderDetail.html?id='+code,
        success(res) {},
        fail(err){},
    })
  },
  seeReseon(e){
    var re = e.currentTarget.dataset.re;
    wx.showModal({
      title: '拒绝原因',
      content:re,
      showCancel:false
    })
  },
  getIndex(id){
    var that = this;
    utils.request('refund/query/'+id,{}, function (res) {
      if (res.data.code == 200) {
        //   if(res.data.data.printOrder.orderStatus==1){
        //     that.setData({
        //       btnHeight:'120rpx'
        //     })
        //   }
          that.setData({
            list:res.data.data
          })
      } else {
        wx.hideLoading()
        utils.toast(res.data.msg)
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      var that = this;
    that.setData({
      id:options.id
    })
      that.getIndex(options.id);
      wx.getSystemInfo({
        success: (result) => {
          var model = result.model;
          if(model=='iPhone X'){
              that.setData({
                pdbottom:'68',
              })
          }else{
            that.setData({
                pdbottom:'40'
            })
          }
        },
      })
  },
  callTel(e){
    var tel = e.currentTarget.dataset.tel;
    wx.makePhoneCall({
      phoneNumber: tel
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    if (that.data.firstOpen == 1) {
      that.getIndex(that.data.id);
    } else {
      that.setData({
        firstOpen: 1
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },
  jt(e){
    var orderId = e.currentTarget.dataset.orderid;
    wx.setClipboardData({
      data:orderId,
      success: function (res) {
      },
    })

  },
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  }
})